<?php

class Admin_Form_Adduserform extends Zend_Form
{

    public function init()
    {
        $this->setAction("./add")->setMethod("post");
        /*
        $username = $this->createElement("text", "username", 
        	array('label' => 'Username'));
        	$username->addValidator(new Zend_Validate_Db_NoRecordExists('users', 'username'));
        	$username->setRequired(true);
        */
        
        $username = new Zend_Form_Element_Text('username',
			 array('label' => 'Username',
			     'required' => true,
			     'filters' => array('StripTags', 'StringTrim'),         
			     'validators' => array('NotEmpty', array('Db_NoRecordExists',false,array(
			  							'users','username', 'messages' => array( Zend_Validate_Db_Abstract::ERROR_RECORD_FOUND => '%value% already exists')
										 ))
		 							)
		 	)
		 );
        
        	
        $password = $this->createElement("password", "password");
        $realname = $this->createElement("text", "realname");
        $submit = $this->createElement("submit", "Add");
        
        $username->removeDecorator("HtmlTag")->removeDecorator("label");
        $password->removeDecorator("HtmlTag")->removeDecorator("label");
        $realname->removeDecorator("HtmlTag")->removeDecorator("label");
        $submit->removeDecorator("DtDdWrapper");
        
        $this->addElements(array($username, $password, $realname, $submit));
    }
}

